home *** CD-ROM | disk | FTP | other *** search
- Path: atglab.bls.com!Alun.Champion
- From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
- Newsgroups: comp.lang.c
- Subject: Re: typedef double Poly[MAXPOLY] PROBLEM
- Date: 11 Jan 1996 15:14:13 GMT
- Organization: Computer People Inc.
- Message-ID: <ALUN.CHAMPION.96Jan11101413@g7240065.bridge.bst.bls.com>
- References: <4d2leh$14dm@pulp.ucs.ualberta.ca>
- NNTP-Posting-Host: bstfirewall.bst.bls.com
- In-reply-to: ryangall@gpu.srv.ualberta.ca's message of 11 Jan 1996 09:32:01
- GMT
-
- In article <4d2leh$14dm@pulp.ucs.ualberta.ca> ryangall@gpu.srv.ualberta.ca (Bobby Sixkiller) writes:
-
- : how can I send a (pointer to Poly) to a function, and access each index
- : for updating? this is my definition....its for school, and the typedef
- : double poly[MAXDEGREE] cannot be changed.....heres an example of one of
- : the functions I tried. It bails out at n=4 ...probably cause thats the
- : size of the pointer......it keeps crashing
-
- : #define MAXDEGREE 200
-
- : typedef double Poly[MAXDEGREE];
- : typedef Poly * POLY;
-
- : /* initialize the Poly P so all index's are 0 */
-
- : int initPoly(POLY P)
- : {
- : int n;
- : for(n=0; n<MAXDEGREE; n++)
- : {
- : *P[n]=0.0; /* can you see what Im trying to do here?!*/
-
- Yes.
- (*P)[n] = 0.0; /* Need parenthisis because of operator precedence.
- or equivalently ;')
- P[0][n] = 0.0;
-
- : }
- : }
-
- The extra pointer indirection is unnecessary in this context
-
- typedef double* POLY;
-
- int
- initPoly(POLY P)
- {
- int n;
- for(n = 0; n < MAXDEGREE; n++) {
- P[n]=0.0;
- }
- }
-
- would be sufficient.
-
- Hope this helps
- Regards
-
- -A.
- --
- | A.Champion |
-